/**
 * Created by zhangdi on 2021/01/31 16:33:06.
 */
public class test2 {
    int flag = 0;

    void aaa() {
        while (true) {
            try {
                System.out.println("flag sleep " + flag);
                Thread.sleep(5000);
            } catch (InterruptedException e) {
                System.out.println("中断了");
                return;
            }

            for (int i = 0; i < 1; i++) {
                System.out.println(flag);
            }
            ++flag;
        }
    }

    Thread thread;

    void start() {
        thread = new Thread(this::aaa);
        thread.start();
    }

    public static void main(String[] args) {
        test2 t = new test2();
        t.start();

//        try {
//            Thread.sleep(3000);
//            t.thread.interrupt();
//        } catch (InterruptedException e) {
//            e.printStackTrace();
//        }
    }
}
